@extends('admin.layouts.index')
@section('title', '用户列表')

@section('content')
<div class="row">
    <div class="col-md-12">
        <div class="card">
            <div class="card-body">
                <form class="m-search" method="GET" action="{{ URL::current() }}">
                    <div class="m-search-items">
                        <div class="m-search-item">
                            <input type="text" name="nike" value="" placeholder="请输入用户ID/昵称/账号">
                        </div>
                        <div class="m-search-item">
                            <button class="button">立即搜索</button>
                        </div>
                    </div>
                    <div class="m-search-handle">
                        <a href="{{ url('/admin/users/users_add') }}" class="button">
                            <i class="bx bx-plus-circle"></i>
                            添加用户
                        </a>
                        <a href="{{ url('/admin/manage/users_static') }}" class="button bg-dark">
                            <i class="bx bx-pie-chart-alt-2"></i>注册统计
                        </a>
                    </div>
                </form>
                <div class="self-table-responsive">
                    <table class="table table-bordered table-nowrap">
                        <thead>
                            <tr>
                                <th scope="col">账号</th>
                                <th scope="col">状态</th>
                                <th scope="col">跟进状态</th>
                                <th scope="col">自动电销</th>
                                <th scope="col">会员等级</th>
                                <th scope="col">会员到期</th>
                                <th scope="col">外链数量</th>
                                <th scope="col">邀请人</th>
                                <th scope="col">关键词来源</th>
                                <th scope="col">邀请码</th>
                                <th scope="col">设备类型</th>
                                <th scope="col">创建时间</th>
                                <th scope="col">操作</th>
                            </tr>
                        </thead>
                        <tbody>
                            @forelse($users as $user)
                            <tr>
                                <td>{{ empty($user->username) ? "-" : $user->username }}</td>
                                @if($user->disable == 1)
                                <td class="text-success">可用</td>
                                @else
                                <td class="text-danger">禁用</td>
                                @endif
                                @if($user->status == 1)
                                <td class="text-warning">未跟进</td>
                                @elseif($user->status == 2)
                                <td class="text-info">无法接通</td>
                                @elseif($user->status == 3)
                                <td class="text-success">有意向</td>
                                @elseif($user->status == 4)
                                <td class="text-danger">无意向</td>
                                @elseif($user->status == 5)
                                <td class="text-warning">待跟进</td>
                                @elseif($user->status == 6)
                                <td class="text-info">任务已提交</td>
                                @elseif($user->status == 7)
                                <td class="text-success">已拨打</td>
                                @endif
                                <td>{{ empty($user->endreason) ? '-' : $user->endreason }}</td>
                                <td>{{ $user->product_id }}</td>
                                <td>{{ $user->member_time }}</td>
                                <td>{{ $user->links_count }}</td>
                                @if(!empty($user->users_invitation_id))
                                <td><a href="{{ url('/admin/users/users_detial',['id'=>$user->users_invitation_id]) }}">{{ empty($user->invitate_name) ? "未命名" : $user->invitate_name }}</a></td>
                                @else
                                <td>-</td>
                                @endif
                                @if(strpos($user->keyword, '%E') !== false)
                                <td>{{ urldecode($user->keyword) }}</td>
                                @else
                                <td>{{ empty($user->keyword) ? "-" : $user->keyword }}</td>
                                @endif
                                <td>{{ empty($user->code) ? "-" : $user->code }}</td>
                                <td>{{ $devices[$user->device] }}</td>
                                <td>{{ $user->created_at }}</td>
                                <td>
                                    <div class="table-handdle-td">
                                        <a href="{{ url('/admin/users/users_detial',['users_id'=>$user->id]) }}" class="table-handdle-link">用户详情</a>
                                        <div class="dropdown-handle table-handdle-menu" data-bs-toggle="dropdown" aria-expanded="false">
                                            <font>更多操作</font>
                                            <i class="bx bx-chevron-down"></i>
                                        </div>
                                        <div class="dropdown-menu">
                                            <a href="{{ url('/admin/users/users_update',['users_id'=>$user->id]) }}" class="dropdown-item" target="_blank">更新用户信息</a>
                                            <a class="dropdown-item" href="{{ url('/admin/manage/user_login',['users_id'=>$user->id]) }}" target="_blank">登录用户账号</a>
                                        </div>
                                    </div>
                                </td>
                            </tr>
                            @empty
                            <tr>
                                @if(Auth::user()->authority == 3)
                                <td colspan="8">暂无用户数据</td>
                                @else
                                <td colspan="8">暂无用户数据,您可以<a href="{{ url('/admin/users/agent_code') }}" target="_blank">分享给您朋友赚收益</a>！</td>
                                @endif
                            </tr>
                            @endforelse
                        </tbody>
                    </table>
                </div>

                <div class="pagination-container">
                    {!! $users->appends($condition)->render() !!}
                    <input type="hidden" name="" id="copy">
                </div>
            </div>
        </div>
    </div>
</div>

@endsection
